package com.opengw.configuration.dao;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.opengw.configuration.route.Route;

@Repository("routeDAO")
public class RouteDAO {
	@Autowired
	private SessionFactory sessionFactory;
	
	@Transactional(propagation=Propagation.REQUIRED)
	public Route getSelectedRoute(long routeId){
		Session session = sessionFactory.getCurrentSession();
		Route route = (Route) session.createCriteria(Route.class).add(Restrictions.idEq(routeId)).uniqueResult();
		return route;
	}
}
